<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= title || 'Minecraft面板' %></title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        
        .anime-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            transition: all 0.3s ease;
        }
        
        .anime-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
        }
        
        .anime-button {
            background: linear-gradient(45deg, #ff6b6b, #ee5a24);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 25px;
            font-weight: 500;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(238, 90, 36, 0.3);
        }
        
        .anime-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(238, 90, 36, 0.4);
        }
        
        .anime-input {
            background: rgba(255, 255, 255, 0.9);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 15px;
            padding: 12px 16px;
            transition: all 0.3s ease;
        }
        
        .anime-input:focus {
            outline: none;
            border-color: #ff6b6b;
            box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
        }
        
        .anime-nav {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .anime-nav-item {
            color: rgba(255, 255, 255, 0.8);
            transition: all 0.3s ease;
            padding: 8px 16px;
            border-radius: 10px;
        }
        
        .anime-nav-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }
        
        .anime-nav-item.active {
            background: rgba(255, 255, 255, 0.2);
            color: white;
        }
        
        .status-online {
            background: linear-gradient(45deg, #00b894, #00cec9);
        }
        
        .status-offline {
            background: linear-gradient(45deg, #e17055, #d63031);
        }
        
        .status-running {
            background: linear-gradient(45deg, #00b894, #55efc4);
        }
        
        .status-stopped {
            background: linear-gradient(45deg, #fdcb6e, #e17055);
        }
        
        .anime-gradient-text {
            background: linear-gradient(45deg, #ff6b6b, #ee5a24);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .anime-modal {
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(5px);
        }
        
        .anime-modal-content {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        }
        
        .loading-spinner {
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top: 3px solid #ff6b6b;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .anime-badge {
            background: linear-gradient(45deg, #a29bfe, #6c5ce7);
            color: white;
            padding: 4px 12px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
        }
        
        .anime-sidebar {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-right: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .terminal {
            background: #1a1a1a;
            color: #00ff00;
            font-family: 'Courier New', monospace;
            border-radius: 10px;
            padding: 16px;
            height: 400px;
            overflow-y: auto;
        }
        
        .terminal-input {
            background: transparent;
            border: none;
            color: #00ff00;
            font-family: 'Courier New', monospace;
            outline: none;
            width: 100%;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="anime-nav p-4">
        <div class="container mx-auto flex justify-between items-center">
            <div class="flex items-center space-x-4">
                <i class="fas fa-cube text-white text-2xl"></i>
                <h1 class="text-white text-xl font-bold">Minecraft面板</h1>
            </div>
            
            <% if (user) { %>
                <div class="flex items-center space-x-4">
                    <a href="/dashboard" class="anime-nav-item <%= active === 'dashboard' ? 'active' : '' %>">
                        <i class="fas fa-tachometer-alt mr-2"></i>仪表板
                    </a>
                    <a href="/servers" class="anime-nav-item <%= active === 'servers' ? 'active' : '' %>">
                        <i class="fas fa-server mr-2"></i>服务器
                    </a>
                    <% if (user.role === 'admin') { %>
                        <a href="/nodes" class="anime-nav-item <%= active === 'nodes' ? 'active' : '' %>">
                            <i class="fas fa-network-wired mr-2"></i>节点
                        </a>
                        <a href="/settings" class="anime-nav-item <%= active === 'settings' ? 'active' : '' %>">
                            <i class="fas fa-cog mr-2"></i>设置
                        </a>
                    <% } %>
                    <div class="flex items-center space-x-2">
                        <img src="https://picsum.photos/seed/<%= user.username %>/32/32.jpg" alt="Avatar" class="w-8 h-8 rounded-full">
                        <span class="text-white"><%= user.username %></span>
                        <a href="/auth/logout" class="anime-nav-item">
                            <i class="fas fa-sign-out-alt"></i>
                        </a>
                    </div>
                </div>
            <% } else { %>
                <div class="flex items-center space-x-4">
                    <a href="/login" class="anime-nav-item <%= active === 'login' ? 'active' : '' %>">
                        <i class="fas fa-sign-in-alt mr-2"></i>登录
                    </a>
                    <a href="/register" class="anime-nav-item <%= active === 'register' ? 'active' : '' %>">
                        <i class="fas fa-user-plus mr-2"></i>注册
                    </a>
                </div>
            <% } %>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main class="container mx-auto p-6">
        <%- body %>
    </main>

    <!-- 页脚 -->
    <footer class="text-center text-white py-8 mt-12">
        <p>© 2024 Minecraft面板. 使用二次元风格设计</p>
    </footer>

    <!-- JavaScript -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // 通用JavaScript函数
        function showLoading(element) {
            $(element).html('<div class="loading-spinner mx-auto"></div>');
        }
        
        function hideLoading(element, content) {
            $(element).html(content);
        }
        
        function showAlert(message, type = 'info') {
            const alertClass = {
                'success': 'bg-green-500',
                'error': 'bg-red-500',
                'warning': 'bg-yellow-500',
                'info': 'bg-blue-500'
            }[type];
            
            const alert = $(`
                <div class="fixed top-4 right-4 ${alertClass} text-white px-6 py-3 rounded-lg shadow-lg z-50">
                    ${message}
                </div>
            `);
            
            $('body').append(alert);
            
            setTimeout(() => {
                alert.fadeOut(() => alert.remove());
            }, 3000);
        }
        
        function confirmAction(message, callback) {
            if (confirm(message)) {
                callback();
            }
        }
        
        // AJAX错误处理
        $(document).ajaxError(function(event, jqXHR, settings, thrownError) {
            showAlert('请求失败: ' + (jqXHR.responseJSON?.error || thrownError), 'error');
        });
        
        // 表单提交处理
        $('form').on('submit', function(e) {
            e.preventDefault();
            const form = $(this);
            const url = form.attr('action');
            const method = form.attr('method') || 'POST';
            const data = form.serialize();
            
            $.ajax({
                url: url,
                method: method,
                data: data,
                success: function(response) {
                    if (response.success) {
                        showAlert(response.message || '操作成功', 'success');
                        if (form.data('redirect')) {
                            setTimeout(() => {
                                window.location.href = form.data('redirect');
                            }, 1000);
                        }
                    } else {
                        showAlert(response.error || '操作失败', 'error');
                    }
                }
            });
        });
        
        // 页面加载完成后的初始化
        $(document).ready(function() {
            // 添加页面加载动画
            $('body').fadeIn(300);
        });
    </script>
    
    <!-- 页面特定脚本 -->
    <%- scripts %>
</body>
</html>